package List;

import org.slf4j.LoggerFactory;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;

/**
 * @Author:Cjj
 * CallerRunsPolicy:拒绝策略有什么风险？如何解决
 */
public class ThreadPoolTest {
    private static final Logger log= (Logger) LoggerFactory.getLogger(ThreadPoolTest.class);

    public static void main(String[] args) {
        //创建一个线程池,核心线程数为1,最大线程数为2
        //当线程数大于核心线程数时,多余的空闲线程存活的最长时间为60秒,任务队列为容量为1的ArrayBlockingQueue,
        //饱和策略为CallerRunsPolicy.
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 2, 60, TimeUnit.SECONDS,
                new ArrayBlockingQueue<Runnable>(1), new ThreadPoolExecutor.CallerRunsPolicy());
    }
}
